<template>
	<view class="all">
		<view style="width: 750upx;height: 176upx;">
			<image src="../../static/shangmen/bj.png" style="width: 750upx;height: 176upx;position: absolute;"></image>
			<view style="display: flex;" @click="shangyibu">
				<view style="position: absolute;display: flex;margin-left: 20upx;line-height: 176upx;">
					<image src="../../static/shangmen/29.png" style="width: 38upx;height: 38upx;margin-top: 72upx;"></image>
				</view>
				<view style="width: 750upx;height: 176upx;text-align: center;font-size: 36upx;line-height: 176upx;position: absolute;z-index: 1;color: #fff;">确认订单</view>
			</view>
		</view>
		<view class="address" v-if="list_data != null" @click="add_address">
			<view style="display: flex;">
				<image src="../../static/shangmen/shouhuodizhi.png" style="width: 34upx;height: 34upx;"></image>
				<view class="address_title"> {{list_data.name}} {{list_data.phone}} </view>
			</view>
			<view class="address_titles">
				<!-- <uni-icons type="location-filled" size="15"></uni-icons> -->
				<view class="address_titles_text"> {{list_data.province}} {{list_data.city}} {{list_data.region}} {{list_data.address}}</view>
				<image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -6upx;"></image>
			</view>
			<image src="../../static/shangmen/30.png" style="width: 630upx;height: 5upx;margin-top: 32upx;margin-left: 0;"></image>
		</view>
		<view class="address" v-if="list_data == null" @click="add_address">
			<view class="address_title"> 添加地址 </view>
			<view class="address_titles">
				<view class="address_titles_text"> 添加地址</view>
				<image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -6upx;"></image>
			</view>
			<image src="../../static/shangmen/30.png" style="width: 630upx;height: 5upx;margin-top: 32upx;margin-left: 0;"></image>
		</view>
		
		<!-- <view style="width: 630upx;background: #fff;padding: 30upx;display: flex;justify-content: space-between;border-radius: 20upx;margin-left: 20upx;margin-top: 20upx;">
			<view style="color: #333333;font-size: 30upx;">预约上门</view>
			<view style="display: flex;">
				<view style="color: #333333;font-size: 30upx;font-weight: bold;"> 
					<uni-section :title="'请选择上门时间：' + datetimesingle" type="date" :start="start_placeholder" :end="end_placeholder"></uni-section>
					<uni-datetime-picker :start="start_placeholder" :end="end_placeholder" type="date" v-model="datetimesingle" @change="changeLog" />
				</view>
			</view>
			<view style="display: flex;">
				<view style="color: #333333;font-size: 30upx;font-weight: bold;"> 
					<picker mode="time" :value="time" start="08:00" end="20:00" @change="bindTimeChange">
						<view style="color: #333333;font-size: 30upx;font-weight: bold;"> {{time==''?'选择时间':time}}  </view>
					</picker>
				</view>
				<image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -0upx;"></image>
			</view>
		</view> -->
		<view style="width: 630upx;background: #fff;padding: 30upx;display: flex;justify-content: space-between;border-radius: 20upx;margin-left: 20upx;margin-top: 20upx;" @click="is_tan_tap">
			<view style="color: #333333;font-size: 30upx;">选择门店地址</view>
			<view style="display: flex;">
				<view style="color: #333333;font-size: 30upx;font-weight: bold;">
					{{shop_name==''?'选择门店地址':shop_name}}
				</view>
				<image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -0upx;"></image>
			</view>
		</view>
		<view class="content">
			<view class="content_top">
				<image mode="aspectFill" class="content_top_image" :src="data_list.image"></image>
				<view class="content_top_text">
					<view class="content_top_text_title">{{data_list.name}}</view>
					<view class="content_top_text_titless" v-if="type != 3">¥{{data_list.price}}</view>
					<!-- <view class="content_top_text_titless" style="color: #333;" v-if="type == 3">￥{{data_list.price}}</view> -->
					<view>
						<uni-number-box v-model="number" :min="1"/>
					</view>
				</view>
			</view>
			<view class="content_box" style="border-top: 1upx solid #EEEEEE;padding-top: 20upx;" @click="is_tan_new_tap">
				<view style="display: flex;">
					<image src="../../static/shangmen/24.png" style="width: 34upx;height: 34upx;margin-top: 6upx;margin-right: 8upx;"></image>
					<view class="content_box_text">优惠券</view>
				</view>
				<view style="display: flex;">
					<view class="content_box_text" style="color: #EA4E29;">{{coupon_money == ''?'请选择优惠券':coupon_money}}</view>
					<image src="../../static/shangmen/23.png" style="width: 34upx;height: 34upx;margin-top: 6upx;margin-left: 8upx;"></image>
				</view>
			</view>
			<view class="content_box" style="border-top: 1upx solid #EEEEEE;padding-top: 20upx;height: 45rpx;">
				<view style="color: #333333;font-size: 30upx;">预约上门</view>
				<view style="display: flex;">
					<view style="color: #333333;font-size: 30upx;"> 
						<uni-section :title="'请选择上门日期：' + datetimesingle" type="date" :start="start_placeholder" :end="end_placeholder"></uni-section>
						<uni-datetime-picker :start="start_placeholder" :end="end_placeholder" type="date" v-model="datetimesingle" @change="changeLog" />
					</view>
					<!-- <image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -0upx;"></image> -->
				</view>
				<view style="display: flex;">
					<view style="color: #333333;font-size: 30upx; height: 45rpx; overflow: hidden;"> 
						<picker mode="time" :value="time" start="08:00" end="20:00" @change="bindTimeChange">
							<view style="color: #333333;font-size: 30upx;"> {{time==''?'选择时间':time}}  </view>
						</picker>
					</view>
					<image src="../../static/shangmen/23.png" style="width: 40upx;height: 40upx;margin-top: -0upx;"></image>
				</view>
			</view>
			<view class="content_box" style="border-top: 1upx solid #EEEEEE;padding-top: 20upx;">
				<view class="content_box_text">商品金额</view>
				<view class="content_box_text" v-if="type != 3">￥{{data_list.price * number}}</view>
				<view class="content_box_text" v-if="type == 3">￥{{data_list.price * number}}</view>
			</view>
			<view class="content_box" style="border-top: 1upx solid #EEEEEE;padding-top: 20upx;">
				<textarea class="uni-input content_box_text" v-model="remark" focus placeholder="添加备注" style="width:100%"  />
			</view>
		</view>
		<!-- <view class="content_box" style="display: flex; justify-content:space-between;margin-left: 20upx;width: 700upx;padding: 20upx 0;">
			<view class="content_box_text">交易密码</view>
			<input class="content_box_text" style="border-bottom: 1upx solid #EEEEEE;text-align: right;" placeholder="请输入交易密码" @input="jiaoyi_input" />
		</view> -->
		<!-- <view style="width: 100%;height: 22upx;background: #EEEEEE;"></view> -->
		<!-- <view class="pay" v-if="key == 1">
			<view class="pay_title">支付方式</view>
			<view class="pay_list">
				<view class="pay_list_box" @click="pay_tap(2)">
					<view class="pay_list_boxs">
						<image class="pay_list_boxs_image" src="../../../static/11.png"></image>
						<view class="pay_list_boxs_text">支付宝支付</view>
					</view>
					<image @click="pay_tap(2)" class="pay_list_box_image" :src="pay_key == 1?'../../../static/5.png':'../../../static/6.png'"></image>
				</view>
				<view class="pay_list_box" @click="pay_tap(1)">
					<view class="pay_list_boxs">
						<image class="pay_list_boxs_image" src="../../../static/10.png"></image>
						<view class="pay_list_boxs_text">微信支付</view>
					</view>
					<image @click="pay_tap(1)" class="pay_list_box_image" :src="pay_key == 2?'../../../static/5.png':'../../../static/6.png'"></image>
				</view>
			</view>
		</view> -->
		<!-- <view class="text">应付金额：<text style="color: #EA4E29;font-size: 36upx;">￥{{money}}</text> </view> -->
		<!-- <view class="text" v-if="type == 3">应付金额：<text style="color: #EA4E29;font-size: 36upx;">￥{{data_list.price}}</text> </view> -->
		<!-- <view class="bottom_all" @click="zhifula">立即支付</view> -->
		<view style="width: 690upx;height: 120upx;display: flex;position: fixed;bottom: 0;z-index: 1;justify-content: space-between;padding: 0 30upx;background: #fff;">
			<view style="font-size: 26upx;color: #333333;line-height: 120upx;">实付金额: <text style="font-size: 32upx;color: #F83B3C;line-height: 120upx;margin-left: 10upx;"> {{money}} </text> </view>
			<view style="width: 240upx;height: 80upx;text-align: center;line-height: 80upx;background: #1C336B;border-radius: 70upx;margin-top: 20upx;color: #fff;font-size: 30upx;" @click="zhifula"> 立即支付 </view>
		</view>
		<view class="is_tan" v-if="is_tan == 1">
			<view class="is_tan_box">
				<view style="width: 750upx;background: #fff;height: auto;position: fixed;bottom: 0;border-radius: 20upx 20upx 0 0;">
					<view style="display: flex;">
						<view style="width: 750upx;height: 110upx;background: #F7F7F9;text-align: center;line-height: 110upx;font-size: 34upx;color: #333333;border-radius: 20upx 20upx 0 0;">选择门店地址</view>
						<image src="../../static/shangmen/28.png" style="width: 48upx;height: 48upx;position: absolute;margin-left: 672upx;margin-top: 32upx;" @click="is_tan_gb"></image>
					</view>
					<scroll-view scroll-y class="is_tan_box_list">
						<view class="is_tan_box_list_box" v-for="(item,index) in shop_data" :key="index" @click="shop_tap(index)">
							<image class="is_tan_box_list_img" :src="item.is_show == 1?'../../static/shangmen/9.png':'../../static/shangmen/10.png'"></image>
							<view class="is_tan_box_list_text">
								<view class="is_tan_box_list_texta">
									<view style="width: 400upx;white-space:break-word;font-size: 30upx;color: #333333;">{{item.name}}</view>
									<view style="font-size: 26upx;color: #603D30;white-space:break-word;">距您 {{item.distance}}KM</view>
								</view>
								<view style="font-size: 26upx;color: #999999;margin-top: 8upx;white-space:break-word;">{{item.province}}{{item.city}}{{item.region}}{{item.address}}</view>
								<view style="font-size: 26upx;color: #999999;margin-top: 8upx;white-space:break-word;" @click.stop="phone_api(item.phone)">联系方式：{{item.phone}}</view>
							</view>
						</view>
					</scroll-view>
					<view style="font-size: 32upx;color: #FFFFFF;text-align: center;line-height: 88upx;width: 690upx;background: #1C346D;border-radius: 30upx;margin-left: 30upx;position: fixed;bottom: 20upx;" @click="shop_id_tap()">确定</view>
				</view>
			</view>
		</view>
		<view class="is_tan" v-if="is_tan_new == 1">
			<view class="is_tan_box">
				<view style="width: 750upx;background: #fff;height: auto;position: fixed;bottom: 0;border-radius: 20upx 20upx 0 0;">
					<view style="display: flex;">
						<view style="width: 750upx;height: 110upx;background: #F7F7F9;text-align: center;line-height: 110upx;font-size: 34upx;color: #333333;border-radius: 20upx 20upx 0 0;">选择优惠券</view>
						<image src="../../static/shangmen/28.png" style="width: 48upx;height: 48upx;position: absolute;margin-left: 672upx;margin-top: 32upx;" @click="is_tan_new_tap_gb"></image>
					</view>
					<scroll-view scroll-y class="is_tan_box_list">
						<view class="is_tan_box_list_box" :class="item.condition <= totalMoney ? 'enabled' : 'disabled'" v-for="(item,index) in coupons_data" :key="index" v-if="item.status == 0" @click="coupon_xz(index,item)">
							<image class="is_tan_box_list_img" :src="item.is_show == 1?'../../static/shangmen/9.png':'../../static/shangmen/10.png'"></image>
							<view class="is_tan_box_list_text">
								<view class="is_tan_box_list_texta">
									<view style="width: 400upx;white-space:break-word;font-size: 30upx;color: #333333;">优惠券金额：{{item.money}}</view>
									<view style="font-size: 26upx;color: #603D30;white-space:break-word;">{{item.condition <= money ? '可使用' : '不可使用'}}</view>
								</view>
								<view style="font-size: 26upx;color: #999999;margin-top: 8upx;white-space:break-word;">到期时间：{{item.end_time}}</view>
							</view>
						</view>
					</scroll-view>
					<view style="font-size: 32upx;color: #FFFFFF;text-align: center;line-height: 88upx;width: 690upx;background: #1C346D;border-radius: 30upx;margin-left: 30upx;position: fixed;bottom: 20upx;" @click="coupon_qd">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				start_placeholder:'2023-08-01',
				end_placeholder:'2023-09-01',
				datetimesingle: '',
				time:'',
				type:'',
				address_id:'',
				freight:0,
				data_list:{},
				pay_key:2,
				goods_id:'',
				list_data:{},
				consignee:'',
				mobile:'',
				address:'',
				province:'',
				city:'',
				region:'',
				specification:'',
				url:'',
				urls:'',
				phone:'',
				key:'',
				password:'',
				is_tan:0,
				is_tan_new:0,
				longitude:'',
				latitude:'',
				citys:'',
				shop_data:[],
				shop_id:'',
				shop_name:'',
				coupons_data:[],
				coupon_id:'',
				coupon_money:0,
				repetition:0,//重复点击
				remark:'',//订单备注
				number:1
			}
		},
		computed:{
			totalMoney(){
				if(this.data_list){
					return this.data_list.price * this.number
				}else {
					return ''
				}
			},
			money(){
				return this.totalMoney - Number(this.coupon_money) + this.freight
			}
		},
		onLoad(num) {
			var that = this
			that.data_list = JSON.parse(num.data_list)
			console.log('that.data_list',that.data_list)
			that.goods_id = that.data_list.goods_id
			that.number =  that.data_list.num
			that.getLaterDate()
			// start_placeholder:'2023-08-01',
			// end_placeholder:'2023-09-01',
			// console.log('currentDate',currentDate)
			// this.type = this.data_list.type
			that.address_index_api()
			that.user_coupons_api()
			uni.getLocation({
				type: 'wgs84',
				success: function (res) {
					console.log('当前位置的经度：' + res.longitude);
					console.log('当前位置的纬度：' + res.latitude);
					that.longitude = res.longitude
					that.latitude = res.latitude
					that.car_shop_api(that.longitude,that.latitude)
				},
				fail(eee) {
					that.longitude = 120.20375
					that.latitude = 30.33018
					that.car_shop_api(that.longitude,that.latitude)
					console.log('eee：' + JSON.stringify(eee));
				}
			});
		},
		onShow() {
			if(this.goods_id!='') {
				this.address_index_api()
			}
		},
		methods: {
			bindTimeChange: function(e) {
				this.time = e.detail.value
			},
			phone_api(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				});

			},
			getLaterDate() {
				var date = new Date();
				var base = Date.parse(date); // 转换为时间戳
				var year = date.getFullYear(); //获取当前年份
				var mon = date.getMonth() + 1; //获取当前月份
				var day = date.getDate(); //获取当前日
				var oneDay = 24 * 3600 * 1000
				var startDate = `${year}-${mon >= 10 ? mon : '0' + mon}-${day >= 10 ? day : '0' + day}`; //今日时间
				this.start_placeholder = this.getLaterDatess(1, new Date(startDate))
				this.end_placeholder = this.getLaterDates(30, new Date(startDate))
			},
			//未来一个月
			getLaterDates(dayNum, dateTime = null) {
				// 如果为null,则格式化当前时间为时间戳
				if (!dateTime) dateTime = +new Date();
				// 如果dateTime长度为10或者13，则为秒和毫秒的时间戳，如果超过13位，则为其他的时间格式
				if (dateTime.toString().length == 10) dateTime *= 1000;
				const timestamp = +new Date(Number(dateTime));
				
				const one_day = 86400000; // 24 * 60 * 60 * 1000;
				const addVal = dayNum * one_day + timestamp;
				//x天后的日期
				const date = new Date(addVal);
				
				//格式化日期
				const filters = n => {
					return n < 10 ? (n = '0' + n) : n;
				};
				const month = filters(date.getMonth() + 1);
				const day = filters(date.getDate());
				const hours = filters(date.getHours());
				const minutes = filters(date.getMinutes());
				const seconds = filters(date.getSeconds());
				
				const lastTime = `${date.getFullYear()}-${month}-${day}`;
				return lastTime;
			},
			//未来一个天
			getLaterDatess(dayNum, dateTime = null) {
				// 如果为null,则格式化当前时间为时间戳
				if (!dateTime) dateTime = +new Date();
				// 如果dateTime长度为10或者13，则为秒和毫秒的时间戳，如果超过13位，则为其他的时间格式
				if (dateTime.toString().length == 10) dateTime *= 1000;
				const timestamp = +new Date(Number(dateTime));
				
				const one_day = 86400000; // 24 * 60 * 60 * 1000;
				const addVal = dayNum * one_day + timestamp;
				//x天后的日期
				const date = new Date(addVal);
				
				//格式化日期
				const filters = n => {
					return n < 10 ? (n = '0' + n) : n;
				};
				const month = filters(date.getMonth() + 1);
				const day = filters(date.getDate());
				const hours = filters(date.getHours());
				const minutes = filters(date.getMinutes());
				const seconds = filters(date.getSeconds());
				
				const lastTime = `${date.getFullYear()}-${month}-${day}`;
				return lastTime;
			},
			shangyibu() {
				uni.navigateBack()
			},
			coupon_xz(index,item) {
				if(item.condition <= this.money){
					for( let i=0;i<this.coupons_data.length;i++ ) {
						if(index == i) {
							if( this.coupons_data[i].is_show == 0 ) {
								this.coupons_data[i].is_show = 1
							}else{
								this.coupons_data[i].is_show = 0
							}
						}else{
							this.coupons_data[i].is_show = 0
						}
					}
				}
			},
			coupon_qd() {
				if( this.coupons_data.length == 0 ) {
					this.is_tan_new = 0
					return
				}
				for( let i=0;i<this.coupons_data.length;i++ ) {
					if(this.coupons_data[i].is_show == 1) {
						this.coupon_id = this.coupons_data[i].coupon_id
						this.coupon_money = this.coupons_data[i].money
						this.is_tan_new = 0
						console.log('this.coupon_id',this.coupon_id)
						return
					}
				}
				this.is_tan_new = 0
				this.coupon_id = ''
				this.coupon_money = 0
			},
			user_coupons_api() {
				var that = this
				that.$request(that.$Api.user_coupons_api, {
					access_token:uni.getStorageSync('access_token'),
				},"POST").then(res => {
					console.log('res.data.data',res.data.data)
					if( res.data.data.length != 0 ) {
						for( let i=0;i<res.data.data.length;i++ ) {
							res.data.data[i]['is_show'] = 0
							if(res.data.data[i].goods_id && res.data.data[i].goods_id != '' && !res.data.data[i].goods_id.split(",").find(g=>g==that.goods_id)){
								res.data.data[i].status = 1
							}
						}
					}
					that.coupons_data = res.data.data
				})
			},
			shop_tap(index) {
				for( let i=0;i<this.shop_data.length;i++ ) {
					if(index == i) {
						if( this.shop_data[i].is_show == 0 ) {
							this.shop_data[i].is_show = 1
						}else{
							this.shop_data[i].is_show = 0
						}
					}else{
						this.shop_data[i].is_show = 0
					}
				}
			},
			shop_id_tap(shop_id) {
				for( let i=0;i<this.shop_data.length;i++ ) {
					if(this.shop_data[i].is_show == 1) {
						this.shop_id = this.shop_data[i].shop_id
						this.shop_name = this.shop_data[i].name
						this.is_tan = 0
						console.log('this.shop_id',this.shop_id)
						console.log('this.address_id',this.list_data.address_id)
						return
					}
				}
			},
			car_shop_api() {
				var that = this
				that.$request(that.$Api.index_city_api, {
					access_token:uni.getStorageSync('access_token'),
					longitude:that.longitude,
					latitude:that.latitude,
				},"POST").then(res => {
					that.citys = res.data.data.city
					that.car_shop_apis()
				})
			},
			car_shop_apis() {
				var that = this
				that.$request(that.$Api.car_shop_api, {
					access_token:uni.getStorageSync('access_token'),
					longitude:that.longitude,
					latitude:that.latitude,
					city:that.citys
				},"POST").then(res => {
					console.log('res.data.data',res.data.data)
					if( res.data.data.length != 0 ) {
						for( let i=0;i<res.data.data.length;i++ ) {
							res.data.data[i]['is_show'] = 0
						}
					}
					that.shop_data = res.data.data
				})
			},
			is_tan_new_tap() {
				this.is_tan_new = 1
			},
			is_tan_new_tap_gb() {
				this.is_tan_new = 0
			},
			//
			is_tan_tap() {
				this.is_tan = 1
			},
			is_tan_gb() {
				this.is_tan = 0
			},
			changeLog(e) {
				console.log('change事件:', e);
			},
			jiaoyi_input(num) {
				// console.log(num.detail.value)
				this.password = num.detail.value
			},
			//下单
			car_put_api(data) {
				var that = this
				that.$request(that.$Api.car_put_api, data, "POST").then(res => {
					if (res.data.code == 0) {
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: res.data.data.timeStamp,
							nonceStr: res.data.data.nonceStr,
							package:  res.data.data.package,
							signType: 'MD5',
							paySign: res.data.data.paySign,
							success: function (res) {
								that.repetition = 0
								uni.showToast({
									title: '支付成功',
									duration: 2000
								});
								setTimeout(function () {
									uni.navigateBack({
										delta:5
									})
								}, 2000);
							},
							fail: function (err) {
								that.repetition = 0
								console.log('err',err)
								uni.showLoading({
									title: '支付失败',
								});
								setTimeout(function () {
									uni.hideLoading();
								}, 1000);
							}
						});
					} else if(res.data.code == 1) {
						that.repetition = 0
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}else{
						that.repetition = 0
						uni.showModal({
							title: '提示',
							content: res.data.data.RETURN_MSG,
							success: function (ress) {
								if (ress.confirm) {
									console.log('用户点击确定');
									// that.put_index_api(money)
								} else if (ress.cancel) {
									console.log('用户点击取消');
								}
							}
						});
					}
				})
			},
			//小程序支付
			zhifula() {
				var that = this
				//重复点击
				if( that.repetition == 1 ) {
					return
				}
				if( that.list_data == null ) {
					uni.showToast({
					    title: '请添加地址',
						icon:'none',
					    duration: 2000
					});
					return;
				}
				if( that.datetimesingle == '' ) {
					uni.showToast({
					    title: '请选择预约时间',
						icon:'none',
					    duration: 2000
					});
					return;
				}
				if( that.shop_id == '' ) {
					uni.showToast({
					    title: '请选择店铺地址',
						icon:'none',
					    duration: 2000
					});
					return;
				}
				var data = {
					access_token: uni.getStorageSync('access_token'),
					coupon_id:that.coupon_id,
					coupon_money:that.coupon_money,
					shop_id:that.shop_id,
					address_id:that.list_data.address_id,
					// time:that.datetimesingle,
					time:that.datetimesingle+that.time,
					money:that.money,
					goods_id:that.goods_id,
					attr_id:that.data_list.attr_id,
					number:that.number,
					remark:that.remark
				}
				that.repetition = 1
				console.log('data',data)
				that.car_put_api(data)
				// if( that.list_data == null ) {
				// 	uni.showToast({
				// 	    title: '请添加地址',
				// 		icon:'none',
				// 	    duration: 2000
				// 	});
				// 	return;
				// }
				// if( that.password == '' ) {
				// 	uni.showToast({
				// 	    title: '请输入交易密码',
				// 		icon:'none',
				// 	    duration: 2000
				// 	});
				// 	return;
				// }
				// if( that.type == 3 ) {
				// 	var money = that.data_list.price
				// }else{
				// 	var money = that.money
				// }
				
				// if(that.type == 3) {
				// 	that.$request(that.$Api.money_puts_api, {
				// 		access_token: uni.getStorageSync('access_token'),
				// 		money:money,
				// 	}, "POST").then(res => {
				// 		if (res.data.code == 0) {
				// 			that.put_index_api(money)
				// 		} else if(res.data.code == 1) {
				// 			uni.showToast({
				// 				title: res.data.msg,
				// 				duration: 2000,
				// 				icon: 'none'
				// 			});
				// 		}else{
				// 			uni.showModal({
				// 				title: '提示',
				// 				content: res.data.msg,
				// 				success: function (ress) {
				// 					if (ress.confirm) {
				// 						console.log('用户点击确定');
				// 						that.put_index_api(money)
				// 					} else if (ress.cancel) {
				// 						console.log('用户点击取消');
				// 					}
				// 				}
				// 			});
				// 		}
				// 	})
				// 	return
				// }
				// that.$request(that.$Api.put_index_api, {
				// 	access_token: uni.getStorageSync('access_token'),
				// 	goods_id:that.goods_id,
				// 	address_id:that.list_data.address_id,
				// 	money:money,
				// 	password:that.password,
				// }, "POST").then(res => {
				// 	if (res.data.code == 0) {
				// 		uni.showToast({
				// 			title: res.data.msg,
				// 			duration: 2000,
				// 			icon: 'none'
				// 		});
				// 		setTimeout(function () {
				// 			// uni.navigateBack()pages/order/order
				// 			uni.navigateTo({
				// 				url:'/pages/order/order?key=0'
				// 			})
				// 		}, 2000);
				// 		// uni.requestPayment({
				// 		// 	provider: 'wxpay',
				// 		// 	timeStamp: res.data.data.timeStamp,
				// 		// 	nonceStr: res.data.data.nonceStr,
				// 		// 	package:  res.data.data.package,
				// 		// 	signType: 'MD5',
				// 		// 	paySign: res.data.data.paySign,
				// 		// 	success: function (res) {
				// 		// 		uni.showToast({
				// 		// 		    title: '支付成功',
				// 		// 		    duration: 2000
				// 		// 		});
				// 		// 		setTimeout(function () {
				// 		// 		    uni.navigateBack({
				// 		// 		    	delta:5
				// 		// 		    })
				// 		// 		}, 2000);
				// 		// 	},
				// 		// 	fail: function (err) {
				// 		// 		console.log('err',err)
				// 		// 		uni.showLoading({
				// 		// 			title: '支付失败',
				// 		// 		});
				// 		// 		setTimeout(function () {
				// 		// 			uni.hideLoading();
				// 		// 		}, 1000);
				// 		// 	}
				// 		// });
				// 	} else {
				// 		uni.showToast({
				// 			title: res.data.msg,
				// 			duration: 2000,
				// 			icon: 'none'
				// 		});
				// 	}
				// })
			},
			put_index_api(money) {
				var that = this
				that.$request(that.$Api.put_index_api, {
					access_token: uni.getStorageSync('access_token'),
					goods_id:that.goods_id,
					address_id:that.list_data.address_id,
					money:money,
					password:that.password,
				}, "POST").then(res => {
					if (res.data.code == 0) {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
						setTimeout(function () {
							// uni.navigateBack()pages/order/order
							uni.navigateTo({
								url:'/pages/order/order?key=0'
							})
						}, 2000);
						// uni.requestPayment({
						// 	provider: 'wxpay',
						// 	timeStamp: res.data.data.timeStamp,
						// 	nonceStr: res.data.data.nonceStr,
						// 	package:  res.data.data.package,
						// 	signType: 'MD5',
						// 	paySign: res.data.data.paySign,
						// 	success: function (res) {
						// 		uni.showToast({
						// 		    title: '支付成功',
						// 		    duration: 2000
						// 		});
						// 		setTimeout(function () {
						// 		    uni.navigateBack({
						// 		    	delta:5
						// 		    })
						// 		}, 2000);
						// 	},
						// 	fail: function (err) {
						// 		console.log('err',err)
						// 		uni.showLoading({
						// 			title: '支付失败',
						// 		});
						// 		setTimeout(function () {
						// 			uni.hideLoading();
						// 		}, 1000);
						// 	}
						// });
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			address_index_api() {
				var that = this
				that.$request(that.$Api.address_index_api, {
					access_token:uni.getStorageSync('access_token'),
				},"POST").then(res => {
					if( res.data.code == 0 ){
						if( res.data.data.list != null ) {
							that.list_data = res.data.data.list
						}else{
							that.list_data = null
						}
						that.freight = res.data.data.delivery_money
						that.money = Number(res.data.data.delivery_money) + Number(that.data_list.price) 
					}else{
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			pay_tap(num) {
				this.pay_key = num
			},
			add_address() { 
				uni.navigateTo({
					url:'../data/data'
				})
			},
			payment() {
				var that = this
				if(that.consignee == '' || that.phone == '') {
					uni.showToast({
						title: '请填写收获信息',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				that.$request(that.urls, {
					access_token:uni.getStorageSync('access_token'),
					goods_id:that.goods_id,
					address_id:that.address_id,
					money:that.money,
				},"POST").then(res => {
					if( res.data.code == 0 ){
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			//微信支付
			requestPayment_tap(obj) {
				var that = this
				uni.requestPayment({
				    provider: 'wxpay',
				    orderInfo: obj,
				    success: (e) => {
				       uni.showToast({
				       	title: '支付成功',
				       	duration: 2000,
				       	icon:'none'
				       });
				       setTimeout(function () {
				           uni.navigateBack({
				           	delta:1
				           })
				       }, 2000);
				    },
				    fail: (e) => {
						console.log('e.errMsg',e)
				        uni.showModal({
				            content: "支付失败 " + e.errMsg,
				            showCancel: false
				        })
				    },
				    complete: (ee) => {
						console.log('ee',ee)
				    }
				})
			},
			//支付宝
			alipay_api(data) {
				console.log('data',data.data.info)
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: data.data.info,
				    success: (e) => {
				        uni.showToast({
				        	title: '支付成功',
				        	duration: 2000,
				        	icon:'none'
				        });
				        setTimeout(function () {
				            uni.navigateBack({
				            	delta:1
				            })
				        }, 2000);
				    },
				    fail: (e) => {
						that.kaitong_a = 0
				        uni.showModal({
				            content: "支付失败 " + e.errMsg,
				            showCancel: false
				        })
				    },
				    complete: () => {
				    }
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		.all{
			.is_tan{
				.is_tan_box{
					.is_tan_box_list{
						.is_tan_box_list_box{
							.is_tan_box_list_text{
								.is_tan_box_list_texta{
									display: flex;
									justify-content: space-between;
								}
								margin-left: 34upx;
							}
							.is_tan_box_list_img{
								width: 36upx;
								height: 36upx;
								margin-top: 25upx;
							}
							display: flex;
							width: 670upx;
							background: #fff;
							padding: 30upx 40upx;
							border-radius: 20rpx;
							margin: 10rpx;
							box-sizing: border-box;
							width: calc(100% - 20rpx);
						}
						.is_tan_box_list_box.enabled {
							background-color: #fff2f2;
						}
						.is_tan_box_list_box.disabled {
							background-color: #eee;
						}
						// width: 670upx;
						height: 40vh;
						background: #fff;
						padding-bottom: 100upx;
					}
					width: 750upx;
					height: 60vh;
					position: fixed;
					bottom: 0;
					// background: #fff;
				}
				width: 750upx;
				height: 100vh;
				position: fixed;
				bottom: 0;
				z-index: 3;
				background: rgba(0, 0, 0, .5);
			}
			.bottom_all{
				width: 700upx;
				height: 80upx;
				background: #EA4E29;
				border-radius: 6upx;
				text-align: center;
				line-height: 80upx;
				color: #FFFFFF;
				margin-left: 25upx;
				position: fixed;
				bottom: 20upx;
			}
			.text{
				width: 100%;
				font-size: 28upx;
				color: #999999;
				line-height: 34upx;
				margin-top: 328upx;
				text-align: center;
				position: fixed;
				bottom: 120upx;
			}
			.pay{
				.pay_list{
					.pay_list_box{
						.pay_list_box_image{
							width: 28upx;
							height: 28upx;
						}
						.pay_list_boxs{
							.pay_list_boxs_image{
								width: 44upx;
								height: 44upx;
							}
							.pay_list_boxs_text{
								font-size: 28upx;
								color: #333333;
								line-height: 44upx;
								margin-left: 16upx;
							}
							display: flex;
						}
						display: flex;
						justify-content: space-between;
						padding: 38upx 0;
						border-bottom: 1upx solid #eee;
					}
				}
				.pay_title{
					font-size: 28upx;
					color: #333333;
				}
				padding: 25upx;
			}
			.content{
				.content_box{
					margin-top: 20rpx;
					display: flex;
					justify-content: space-between;
				}
				.content_top{
					.content_top_text{
						display: flex;
						flex-direction: column;
						gap:13rpx;
						margin-left: 18upx;
						padding: 10rpx 0;
						.content_top_text_title{
							font-size: 32rpx;
							color: #3D3D3D;
						}
						.content_top_text_titles{
							font-size: 24rpx;
							color: #999999;
						}
						.content_top_text_titless{
							font-size: 40rpx;
							color: #E93131;
						}
					}
					.content_top_image{
						width: 158upx;
						height: 158upx;
					}
					display: flex;
				}
				padding: 30upx;
				width: 630upx;
				margin-left: 20upx;
				background: #fff;
				border-radius: 20upx;
				margin-top: 20upx;
			}
			.address{
				.address_titles{
					.address_titles_text{
						font-size: 28upx;
						color: #222;
						line-height: 30upx;
					}
					display: flex;
					justify-content: space-between;
					margin-top: 15upx;
				}
				.address_title{
					font-size: 32upx;
					color: #222;
					margin-left: 24upx;
				}
				padding: 30upx;
				margin-top: 20upx;
				background: #fff;
				width: 630upx;
				margin-left: 25upx;
				border-radius: 20upx;
			}
			width: 750upx;
		}
		background: #f4f4f4;
	}
	/deep/ .uni-date__x-input {
		font-size: 32rpx !important;
		font-weight: normal;
	}
	/deep/ .uni-numbox__value {
		font-size: 20rpx !important;
		width: 60rpx !important;
		height: 40rpx !important;
	}
	/deep/ .numbox__minus {
		height: 40rpx !important;
	}
</style>
